#include<cstdio>
int n;
int dist[100002];
int m;
int main(){
    scanf("%d",&n);
    int i=2;
    while(i<=n+1){
        int dis;
        scanf("%d",&dis);
        dist[i]=dist[i-1]+dis;
        i++;
    }
    scanf("%d",&m);
    while(m-->0){
        int x,y;
        scanf("%d %d",&x,&y);
        if(x<y){x=x^y;y=x^y;x=x^y;}
        int a=dist[x]-dist[y];
        int b=dist[n+1]-a;
        printf("%d\n",a<b?a:b);
    }
    return 0;
}
